package com.formulas.certification.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;

/**
 * Web安全策略配置
 * @author yiwannuofulasi
 * @date 2023/6/19 10:45
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig {

    /**
     * 允许任何通过身份验证的请求访问
     * @param httpSecurity http安全性
     * @return SecurityFilterChain 安全过滤链
     * @throws Exception exception
     */
    @Bean
    SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.authorizeHttpRequests((auth->{
            auth.requestMatchers("/**")
                    .permitAll()
                    .anyRequest()
                    .authenticated();
        }));
        return httpSecurity.build();
    }
}
